﻿#pragma once

#include <unordered_map>
#include "../share/user_define.h"
#include "../../3rd/libjson/json.h"
#include "../share/common_singleton.h"

/*
"id": 1,
"exp": 25,
"hero_lv_limit": 10,
"power_reward": 20,
"max_power": 60,
" max_friend": 30,
"max_vitality": 10
*/

struct PlayerLevelUp
{
	uint32_t mId;				// 战队级别
	uint32_t mExp;				// 升级所需经验
	uint32_t mHeroLvLimit;		// 英雄级别限制
	uint32_t mPowerReward;		// 战队等级提升获得的体力奖励
	uint32_t mMaxPower;			// 体力上限
	uint32_t mMaxFriend;		// 好友上限
	uint32_t mMaxVitality;		// 活力上限
	uint32_t mResurrectionCD;	// 营地复活CD时间
	uint32_t mdpslimit;			// 玩家对boss的dps，公会boss，组队boss等需要上报服务器伤害的boss使用，做一个初步判定

	PlayerLevelUp()
	{
		Clear();
	}

	void Clear(void)
	{
		mId = 0;
		mExp = 0;
		mHeroLvLimit = 0;
		mPowerReward = 0;
		mMaxPower = 0;
		mMaxFriend = 0;
		mMaxVitality = 0;
		mResurrectionCD = 0;
		mdpslimit = 0;
	}
};

class PlayerLevelUpCacheData : public ::common::CSingleton<PlayerLevelUpCacheData>
{
public:
	~PlayerLevelUpCacheData(void);
	PlayerLevelUpCacheData(void);
public:

	bool Initialization(void);

	bool Reload(void);
	
	PlayerLevelUp* GetData(uint32_t id);

	bool GetDataJsonString(uint32_t id, Json::Value& _jm);

	uint32_t GetDataCount(void);

private:
	void Clear(void);

	void AddData(uint32_t id, Json::Value& jm);
private:
	std::unordered_map<uint32_t, PlayerLevelUp*> m_mapCacheData;
	uint32_t m_maxCount;
};

